<?php
require "common.php";

$username = $_POST['username'];
$password = $_POST['password'];


$aRet = [];
if(trim($username) == "" || trim($password) == ""){
	$aRet['errno']  = "0002";
	$aRet['errmsg'] = "用户名或者密码为空，请重新输入！";
	echo json_encode($aRet);
	exit;
}

$password = md5($password);

$sql = "SELECT * FROM `user` WHERE `user_name` = '$username' AND `user_password` = '$password'";
$aRes = $db->getOneRecord($sql);

if(empty($aRes)){
	$aRet = [];
	$aRet['errno'] = "0003";
	$aRet['errmsg'] = "登陆失败";
	echo json_encode($aRet);
	exit;
}

$aRet = [];
$aRet['errno']   = "0000";
$aRet['errmsg']  = "";
$aRet['user_id'] = intval($aRes['id']);

echo json_encode($aRet);

